#include <iostream>
using namespace std;

int a, b, c, d;

int main()
{
	int e = 0;
	cin >> a >> b >> c >> d; 
	e = c * 60 + d - (a * 60 + b);
	cout << e / 60 << " " << e % 60;
	return 0;
}

